package org.lab.study.basics;

import org.lab.data.Quote;
import org.lab.data.Ticker;
import org.lab.study.Study;


public class AverageIncrease extends Study{
	
	private float profitPercents = 0f;
	private float percentPos = 0;
	
	public AverageIncrease(){};
	
	public void run(Ticker ticker) {
				
		for (Quote quote:ticker.getQuotes()) {
			float profit = ticker.getQuoteUtil().CloseToLastClosePercent(quote);
			profitPercents += profit;
			if (profit>=0) {
				percentPos++;
			}
			amount = amount * (1+profit/100);
		}
		
		profitPercents = profitPercents/ticker.getQuotes().size();
		
		System.out.println("Result of AverageIncrease - Avg Profit: " + profitPercents + "%");
		
		percentPos = percentPos/ticker.getQuotes().size()*100;
		
		System.out.println("Result of AverageIncrease - Profit Ratio: " + percentPos + "%");
		
		System.out.println("Result of AverageIncrease - Cumulative Profit: " + amount + "%");
	}
}
